/**
 * 
 */
package otl;


import java.util.ArrayList;

import processing.core.*;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.marker.SimplePointMarker;
//import de.fhpotsdam.unfolding.utils.MapUtils;
import de.fhpotsdam.unfolding.utils.ScreenPosition;

/**
 * @author Maya
 *
 */
@SuppressWarnings("serial")
public class Station extends PApplet{

	PApplet parent;	
	UnfoldingMap map;
	
	int	id; 		//station id
	String name;	//the name of the building
	
	float geoLong;
	float geoLat;
	PVector geoLoc; // the long/lat coordinate of the station
	String type;	//the type of station
	
	ArrayList<Place> placeList;
	
	/*Data related*/
	Location locationStation;
	
	/*Graphics Related*/
	SimplePointMarker markerStation;
	
		
	Station(PApplet p, UnfoldingMap m, int stationID, String stationName, float stationLong,float stationLat, String stationType) {
		parent = p;
		map = m;
		id = stationID;
		name = stationName;
		geoLong = stationLong;
		geoLat = stationLat;
		type = stationType;
		locationStation = new Location(stationLat, stationLong);
		markerStation = new SimplePointMarker(locationStation);
	}
	
	public void setPlaces(ArrayList<Place> pList){
		//building places for the station
		//println("setting placelist for station id: " + id);
		placeList = pList;
	}

	public int getNumPlaces(){
		return placeList.size();
	}

	public void drawStation(){
		//println("In station with map zoom: " + map.getZoom());
		ScreenPosition posStation = markerStation.getScreenPosition(map);
		
		parent.fill(0,0,255);
		PShape marker;
		marker = parent.createShape();
		marker.beginShape();
			marker.fill(0,0,255);
			marker.vertex(0, 0); //v1
			marker.vertex(10, 0); //v2
			marker.vertex(10, 10);//v3
			marker.vertex(0, 10); //v4
		marker.endShape();
		parent.shape(marker,posStation.x, posStation.y);
		
		parent.fill(0);
		parent.text(this.name, posStation.x - parent.textWidth(this.name) / 2, posStation.y + 4);
		
		
		//drawPlaces();
		
		
	}

	private void drawPlaces(){
		//println("Drawing places for station ID: " + id);
		for(int i = 0; i < placeList.size(); i++) {
			placeList.get(i).drawPlace();
		}
	}

}
